NOTE: PROCEDURE PRINTTO used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

3    
4    DM "log; clear; ";
5    DM 'odsresults; clear';
6    
7    %global projectrootdirectory;
8    %let projectrootdirectory=C:/Users/hpham13/Projects/mf_activism/empirical;
9    
10   *Creates your local Libraries;
11   libname rawdata "&projectrootdirectory./0_input/original";
NOTE: Libref RAWDATA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\Projects\mf_activism\empirical\0_input\original
12   libname rawdata2 "&projectrootdirectory./0_input/original/finaldatadepvars";
NOTE: Libref RAWDATA2 was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: 
      C:\Users\hpham13\Projects\mf_activism\empirical\0_input\original\finaldatadepvars
13   libname save "&projectrootdirectory./0_input/final";
NOTE: Libref SAVE was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\Projects\mf_activism\empirical\0_input\final
14   
15   %let datadirectory= C:/Users/hpham13/data ;
16   
17   libname lnk "&datadirectory./Linking_tables/";
NOTE: Libref LNK was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\Linking_tables
18   libname ceo "&datadirectory./ceo/";
NOTE: Libref CEO was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\ceo
19   libname activism "&datadirectory./activism/" ;
NOTE: Libref ACTIVISM was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\activism
20   libname comp "&datadirectory./compustat/fundq/";
NOTE: Libref COMP was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\compustat\fundq
21   libname compa "&datadirectory./compustat/funda/";
NOTE: Libref COMPA was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\compustat\funda
22   libname ibes "&datadirectory./IBES";
NOTE: Libref IBES was successfully assigned as follows: 
      Engine:        V9 
      Physical Name: C:\Users\hpham13\data\IBES
23   
24   * include some macros;
25   %include "&datadirectory./utils/do_over.sas";
332  %include "&datadirectory./utils/ff48.sas";
404  %include "&datadirectory./utils/ff49.sas";
477  %include "&datadirectory./utils/ff12.sas";
516  %include "&datadirectory./utils/winsorize.sas";
604   %include "&datadirectory./utils/lags.sas";
783   
784   
785   
786   /* ************************************************************************ */
787   /* ***********************  PART 1: IMPORT DATA  ************************** */
788   /* ************************************************************************ */
789   %let fname  = 111624_mff_top5;
790   %let fname2 = 111624_mff_top10;
791   %let fname3 = 111624_mff_top20;
792   %let fname4 = 111624_mff_top3;
793   %let fname5 = 111624_mff_top4;
794   
795   * top 5;
796   data stockpick; set rawdata2.stkpick&fname.;
797       label relstkpick1="RelInformedTrade top5" ;
798   run;

NOTE: There were 238656 observations read from the data set RAWDATA2.STKPICK111624_MFF_TOP5.
NOTE: The data set WORK.STOCKPICK has 238656 observations and 24 variables.
NOTE: DATA statement used (Total process time):
      real time           0.17 seconds
      cpu time            0.01 seconds
      

799   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 238656 observations read from the data set WORK.STOCKPICK.
NOTE: 1523 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK has 237133 observations and 24 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.09 seconds
      

800   
801   * top 10;
802   data stockpick2; set rawdata2.stkpick&fname2.;
803       keep gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
804            numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall ;
805       label relstkpick1="RelInformedTrade top10" ;
806       rename relstkpick1      = relstkpick1_top10;
807       rename avg_stkpick1_all = avg_stkpick1_all_top10;
808       rename stkpick1_large   = stkpick1_large_top10;
809       rename stkpick1_small   = stkpick1_small_top10;
810       rename mfor = mfor_top10;
811       rename numinstlarge = numinstlarge_top10;
812       rename avgmforlarge = avgmforlarge_top10;
813       rename summforlarge = summforlarge_top10;
814       rename numinstsmall = numinstsmall_top10;
815       rename avgmforsmall = avgmforsmall_top10;
816       rename summforsmall = summforsmall_top10;
817   run;

WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 194759 observations read from the data set RAWDATA2.STKPICK111624_MFF_TOP10.
NOTE: The data set WORK.STOCKPICK2 has 194759 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.03 seconds
      

818   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 194759 observations read from the data set WORK.STOCKPICK2.
NOTE: 1070 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK2 has 193689 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.04 seconds
      cpu time            0.06 seconds
      

819   
820   * top 20;
821   data stockpick3; set rawdata2.stkpick&fname3.;
822       keep gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
823            numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall;
824       label relstkpick1="RelInformedTrade top20" ;
825       rename relstkpick1      = relstkpick1_top20;
826       rename avg_stkpick1_all = avg_stkpick1_all_top20;
827       rename stkpick1_large   = stkpick1_large_top20;
828       rename stkpick1_small   = stkpick1_small_top20;
829       rename mfor = mfor_top20;
830       rename numinstlarge = numinstlarge_top20;
831       rename avgmforlarge = avgmforlarge_top20;
832       rename summforlarge = summforlarge_top20;
833       rename numinstsmall = numinstsmall_top20;
834       rename avgmforsmall = avgmforsmall_top20;
835       rename summforsmall = summforsmall_top20;
836   run;

WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 135680 observations read from the data set RAWDATA2.STKPICK111624_MFF_TOP20.
NOTE: The data set WORK.STOCKPICK3 has 135680 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.08 seconds
      cpu time            0.00 seconds
      

837   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 135680 observations read from the data set WORK.STOCKPICK3.
NOTE: 530 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK3 has 135150 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.03 seconds
      cpu time            0.04 seconds
      

838   
839   * top 3;
840   data stockpick4; set rawdata2.stkpick&fname4.;
841       keep gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
842            numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall;
843       label relstkpick1="RelInformedTrade top3" ;
844       rename relstkpick1      = relstkpick1_top3;
845       rename avg_stkpick1_all = avg_stkpick1_all_top3;
846       rename stkpick1_large   = stkpick1_large_top3;
847       rename stkpick1_small   = stkpick1_small_top3;
848       rename mfor = mfor_top3;
849       rename numinstlarge = numinstlarge_top3;
850       rename avgmforlarge = avgmforlarge_top3;
851       rename summforlarge = summforlarge_top3;
852       rename numinstsmall = numinstsmall_top3;
853       rename avgmforsmall = avgmforsmall_top3;
854       rename summforsmall = summforsmall_top3;
855   run;

WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 265466 observations read from the data set RAWDATA2.STKPICK111624_MFF_TOP3.
NOTE: The data set WORK.STOCKPICK4 has 265466 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.14 seconds
      cpu time            0.04 seconds
      

856   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 265466 observations read from the data set WORK.STOCKPICK4.
NOTE: 1868 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK4 has 263598 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.09 seconds
      

857   
858   * top 4;
859   data stockpick5; set rawdata2.stkpick&fname5.;
860       keep gvkey rdq relstkpick1 avg_stkpick1_all stkpick1_large stkpick1_small mfor
861            numinstlarge  avgmforlarge summforlarge numinstsmall avgmforsmall summforsmall;
862       label relstkpick1="RelInformedTrade top4" ;
863       rename relstkpick1      = relstkpick1_top4;
864       rename avg_stkpick1_all = avg_stkpick1_all_top4;
865       rename stkpick1_large   = stkpick1_large_top4;
866       rename stkpick1_small   = stkpick1_small_top4;
867       rename mfor = mfor_top4;
868       rename numinstlarge = numinstlarge_top4;
869       rename avgmforlarge = avgmforlarge_top4;
870       rename summforlarge = summforlarge_top4;
871       rename numinstsmall = numinstsmall_top4;
872       rename avgmforsmall = avgmforsmall_top4;
873       rename summforsmall = summforsmall_top4;
874   run;

WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
WARNING: The variable mfor in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 250929 observations read from the data set RAWDATA2.STKPICK111624_MFF_TOP4.
NOTE: The data set WORK.STOCKPICK5 has 250929 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.13 seconds
      cpu time            0.06 seconds
      

875   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 250929 observations read from the data set WORK.STOCKPICK5.
NOTE: 1671 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK5 has 249258 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.07 seconds
      

876   
877   * Merge datasets;
878   proc sql;
879       create table stockpick as
880       select a.*, b.*, c.*, d.*, e.*
881       from stockpick as a left join stockpick2 as b
882           on a.gvkey=b.gvkey and a.rdq=b.rdq
883       left join stockpick3 as c
884           on a.gvkey=c.gvkey and a.rdq=c.rdq
885       left join stockpick4 as d
886           on a.gvkey=d.gvkey and a.rdq=d.rdq
887       left join stockpick5 as e
888           on a.gvkey=e.gvkey and a.rdq=e.rdq;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
WARNING: Variable gvkey already exists on file WORK.STOCKPICK.
WARNING: Variable rdq already exists on file WORK.STOCKPICK.
NOTE: Table WORK.STOCKPICK created, with 237133 rows and 64 columns.

889   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.40 seconds
      cpu time            0.40 seconds
      

890   data stockpick; set stockpick;
891       format  relstkpick1 relstkpick1_top10 relstkpick1_top20  relstkpick1_top3
891 ! relstkpick1_top4
892               relstkpick2 stkpick1 stkpick2
893               avg_stkpick1_all avg_stkpick2_all stkpick1_Large stkpick1_Small comma8.5;
894   run;

NOTE: There were 237133 observations read from the data set WORK.STOCKPICK.
NOTE: The data set WORK.STOCKPICK has 237133 observations and 64 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.07 seconds
      

895   proc sort nodupkey; by gvkey rdq; run;

NOTE: There were 237133 observations read from the data set WORK.STOCKPICK.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.STOCKPICK has 237133 observations and 64 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.17 seconds
      

896   
897   /* 2. merge stacked data and others */
898   data stacked_data; set rawdata.stacked_data_111624; run;

NOTE: There were 50730 observations read from the data set RAWDATA.STACKED_DATA_111624.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 52 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

899   
900   * make the cohort year;
901   data stacked_data; set stacked_data;
902       if qd_rel = 0 then _cohort_y = fyearq; else _cohort_y = 0;
903   run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 53 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

904   proc sql;
905       create table stacked_data as
906       select *, max(_cohort_y) as cohort_y label='Cohort Year'
907       from stacked_data
908       group by cid ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.STACKED_DATA created, with 50730 rows and 54 columns.

909   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.06 seconds
      

910   data stacked_data; set stacked_data;
911       drop _cohort_y ;
912   run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 53 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

913   proc sort data=stacked_data; by cid pairid treated qd_rel; run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA.
NOTE: The data set WORK.STACKED_DATA has 50730 observations and 53 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

914   
915   * other activism data;
916   data pilot; set activism.ca_details_95_pilot; run;

NOTE: There were 9262 observations read from the data set ACTIVISM.CA_DETAILS_95_PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 147 variables.
NOTE: DATA statement used (Total process time):
      real time           0.06 seconds
      cpu time            0.06 seconds
      

917   proc sort data=pilot nodupkey; by  gvkey CAMPAIGN_ID ; run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.PILOT has 9262 observations and 147 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.11 seconds
      cpu time            0.09 seconds
      

918   
919   *check if two campaigns happens during the period of 8 quarters ;
920   proc sort data=pilot;
921       by gvkey ANNOUNCE_DATE;
922   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 147 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds
      

923   data pilot; set pilot;
924       by gvkey ;
925       ANNOUNCE_DATE_l = lag(ANNOUNCE_DATE);
926       if first.gvkey then ANNOUNCE_DATE_l=.;
927       format ANNOUNCE_DATE_l YYMMDD10. ;
928       * count the number of quarters;
929       days_diff = intck('day', ANNOUNCE_DATE_l, ANNOUNCE_DATE);
930       if ANNOUNCE_DATE_l = . then days_diff = . ;
931       if days_diff ne . then quarter_diff = days_diff/30 ;
932           else quarter_diff = . ;
933       format quarter_diff comma8.1;
934   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4328 at 929:17   
NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 150 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

935   
936   proc sort data=pilot out=pilot;
937       by gvkey descending ANNOUNCE_DATE;
938   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 150 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds
      

939   
940   data pilot;
941       set pilot;
942       by gvkey;
943       retain ANNOUNCE_DATE_f;
944       if first.gvkey then ANNOUNCE_DATE_f = .;
945       ANNOUNCE_DATE_f = lag(ANNOUNCE_DATE);
946       if first.gvkey then ANNOUNCE_DATE_f = .;
947       output;
948   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 151 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

949   
950   data pilot;
951       set pilot;
952       format ANNOUNCE_DATE_f YYMMDD10. ;
953       * count the number of quarters;
954       days_diff_2 = intck('day', ANNOUNCE_DATE, ANNOUNCE_DATE_f);
955       if ANNOUNCE_DATE = . then days_diff_2 = . ;
956       if days_diff_2 ne . then quarter_diff_2 = days_diff_2/30 ;
957           else quarter_diff_2 = . ;
958       format quarter_diff_2 comma8.1;
959   run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      4328 at 954:19   
NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 153 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.06 seconds
      

960   
961   proc sort data=pilot out=pilot;
962       by gvkey ANNOUNCE_DATE;
963   run;

NOTE: There were 9262 observations read from the data set WORK.PILOT.
NOTE: The data set WORK.PILOT has 9262 observations and 153 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds
      

964   
965   * other activism vars;
966   data sharkwatch; set activism.tohai_activists_12032023; run;

NOTE: There were 3023 observations read from the data set ACTIVISM.TOHAI_ACTIVISTS_12032023.
NOTE: The data set WORK.SHARKWATCH has 3023 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

967   proc sort data=sharkwatch nodupkey; by CAMPAIGN_ID; run;

NOTE: There were 3023 observations read from the data set WORK.SHARKWATCH.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.SHARKWATCH has 3023 observations and 5 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

968   
969   * Activist prior experience;
970   data activist_prior_exp;
971       set rawdata.activist_prior_exp;
972   run;

NOTE: There were 2110 observations read from the data set RAWDATA.ACTIVIST_PRIOR_EXP.
NOTE: The data set WORK.ACTIVIST_PRIOR_EXP has 2110 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

973   
974   %let qd = (year(ANNOUNCE_DATE)*4  + qtr(ANNOUNCE_DATE) - 1925*4);
975   data activist_prior_exp; set activist_prior_exp ;
976       if ANNOUNCE_DATE ne . then do ;
977           qd = &qd;
978       end;
979   run;

NOTE: There were 2110 observations read from the data set WORK.ACTIVIST_PRIOR_EXP.
NOTE: The data set WORK.ACTIVIST_PRIOR_EXP has 2110 observations and 21 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

980   proc sort data=activist_prior_exp nodupkey; by gvkey year qd; run;

NOTE: There were 2110 observations read from the data set WORK.ACTIVIST_PRIOR_EXP.
NOTE: 227 observations with duplicate key values were deleted.
NOTE: The data set WORK.ACTIVIST_PRIOR_EXP has 1883 observations and 21 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

981   
982   /* Merge data */
983   proc sql;
984       create table stacked_data2 as
985       select  a.*, b.*, c.*, d.prior_exp,
986               d.mean_prior_exp_sic2, d.med_prior_exp_sic2,
987               d.med_NUMBER_CAMPAIGNS, d.mean_NUMBER_CAMPAIGNS,
988               d.med_ACTIVIST_THREAT_RATING, d.mean_ACTIVIST_THREAT_RATING
989       from    stacked_data as a left join pilot as b
990       on      a.gvkey=b.gvkey and
991               a.FACTSET_ENTITY_ID=b.FACTSET_ENTITY_ID and
992               a.CAMPAIGN_ID=b.CAMPAIGN_ID
993       left join sharkwatch as c
994       on      a.CAMPAIGN_ID=c.CAMPAIGN_ID
995       left join activist_prior_exp as d
996       on      a.gvkey=d.gvkey and a.qd=d.qd ;
WARNING: Variable CAMPAIGN_ID already exists on file WORK.STACKED_DATA2.
WARNING: Variable ANNOUNCE_DATE already exists on file WORK.STACKED_DATA2.
WARNING: Variable FILING_DATE already exists on file WORK.STACKED_DATA2.
WARNING: Variable END_DATE already exists on file WORK.STACKED_DATA2.
WARNING: Variable FACTSET_ENTITY_ID already exists on file WORK.STACKED_DATA2.
WARNING: Variable ENTITY_PROPER_NAME already exists on file WORK.STACKED_DATA2.
WARNING: Variable gvkey already exists on file WORK.STACKED_DATA2.
WARNING: Variable CAMPAIGN_ID already exists on file WORK.STACKED_DATA2.
NOTE: Table WORK.STACKED_DATA2 created, with 50730 rows and 210 columns.

997   quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.43 seconds
      cpu time            1.85 seconds
      

998   proc sort data=stacked_data2 nodupkey; by cID PairID treated qd_rel ; run;

NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA2.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.STACKED_DATA2 has 50730 observations and 210 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.61 seconds
      cpu time            0.60 seconds
      

999   
1000  * create the SIC2 ;
1001  data stacked_data2;
1002      set stacked_data2;
1003      sic_num = input(sic, 8.);
1004      sic2 = floor(sic/100);
1005  run;

NOTE: Character values have been converted to numeric values at the places given by: 
      (Line):(Column).
      1004:18   
NOTE: There were 50730 observations read from the data set WORK.STACKED_DATA2.
NOTE: The data set WORK.STACKED_DATA2 has 50730 observations and 212 variables.
NOTE: DATA statement used (Total process time):
      real time           0.38 seconds
      cpu time            0.39 seconds
      

1006  
1007  * count the number of campaigns per sic2-year ;
1008  proc sql;
1009      create table stacked_data2 as
1010      select
1011          a.*, b.number_campaigns_ind, b.avg_campaigns_ind, b.med_campaigns_ind,
1011! b.sd_campaigns_ind,
1012          b.med_activist_threat_rating, b.sum_activist_threat_rating,
1012! b.avg_activist_threat_rating
1013      from stacked_data2 as a
1014      left join (
1015      select distinct CAMPAIGN_ID, sic2, year
1016          , sum( number_campaigns) as number_campaigns_ind label="N campaigns (industry)"
1017          , mean( number_campaigns) as avg_campaigns_ind format comma8.3
1018          , median( number_campaigns) as med_campaigns_ind format comma8.2
1019          , std( number_campaigns) as sd_campaigns_ind format comma8.2
1020          , median(activist_threat_rating) as med_activist_threat_rating format comma8.2
1021          , avg(activist_threat_rating) as avg_activist_threat_rating format comma8.2
1022          , sum(activist_threat_rating) as sum_activist_threat_rating format comma8.2
1023          from stacked_data2
1024          group by sic2, year
1025          having number_campaigns ne . and activist_threat_rating ne .
1026          ) as b
1027      on  a.CAMPAIGN_ID=b.CAMPAIGN_ID and
1028          a.sic2=b.sic2 and
1029          a.year=b.year  ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable med_activist_threat_rating already exists on file WORK.STACKED_DATA2.
NOTE: Table WORK.STACKED_DATA2 created, with 50730 rows and 218 columns.

1030  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.23 seconds
      cpu time            1.40 seconds
      

1031  
1032  
1033  /* ************************************************************************ */
1034  /* ********************  PART 2: MERGE FUNDQ, FUNDA  ********************** */
1035  /* ************************************************************************ */
1036  * Merge stacked data and MFF stock picking ability;
1037  proc sql;
1038      create table Analysis as
1039      select  a.*, b.*
1040      from    stacked_data2 as a left join stockpick as b
1041      on      a.gvkey=b.gvkey and a.rdq=b.rdq ;
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable datadate already exists on file WORK.ANALYSIS.
WARNING: Variable rdq already exists on file WORK.ANALYSIS.
WARNING: Variable qd already exists on file WORK.ANALYSIS.
WARNING: Variable year already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 50730 rows and 277 columns.

1042  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.97 seconds
      cpu time            1.23 seconds
      

1043  proc sort data=Analysis nodupkey; by cID PairID treated gvkey datadate; run;

NOTE: There were 50730 observations read from the data set WORK.ANALYSIS.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 50730 observations and 277 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.49 seconds
      cpu time            0.48 seconds
      

1044  
1045  * handle outliers;
1046  data Analysis; set Analysis; fyear=year(datadate); run;

NOTE: There were 50730 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 50730 observations and 278 variables.
NOTE: DATA statement used (Total process time):
      real time           0.30 seconds
      cpu time            0.29 seconds
      

1047  %winsor(dsetin=work.Analysis, dsetout=work.Analysis, byvar=fyear, vars=relstkpick1
1047! relstkpick1_top10 relstkpick1_top20 , type=trim, pctl=1 99);

NOTE: There were 50730 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.XTEMP has 50730 observations and 278 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.25 seconds
      


NOTE: There were 50730 observations read from the data set WORK.XTEMP.
NOTE: The data set WORK.XTEMP has 50730 observations and 278 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.49 seconds
      cpu time            0.48 seconds
      

NOTE: Writing HTML Body file: sashtml.htm

NOTE: The data set WORK.XTEMP_PCTL has 28 observations and 7 variables.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
      real time           0.41 seconds
      cpu time            0.28 seconds
      


WARNING: The variable xbyvar in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 50730 observations read from the data set WORK.XTEMP.
NOTE: There were 28 observations read from the data set WORK.XTEMP_PCTL.
NOTE: The data set WORK.ANALYSIS has 49535 observations and 278 variables.
NOTE: DATA statement used (Total process time):
      real time           0.30 seconds
      cpu time            0.29 seconds
      

1048  data Analysis; set Analysis; drop fyear ; run;

NOTE: There were 49535 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 49535 observations and 277 variables.
NOTE: DATA statement used (Total process time):
      real time           0.34 seconds
      cpu time            0.31 seconds
      

1049  proc sql;
1049!           drop table xtemp, xtemp_pctl;
NOTE: Table WORK.XTEMP has been dropped.
NOTE: Table WORK.XTEMP_PCTL has been dropped.
1049!                                         quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds
      

1050  
1051  data fundq_clean;
1052      set rawdata.comp_fundq_clean;
1053      keep gvkey rdq datadate fyearq fyr fqtr be bd ppegtq PnI saleq to dlttq dlcq
1054      oibdpq oiadpq pm ic tacq revq drevq drevadjq ppeq roaq roaq_lag1 me ml bm
1055      atq_lag1 saleq_lag1 rectq_lag1 ibq ibq_lag1 size size_l lvrg_l lvrg seqq ltq niq niq_l
1055! ;
1056      if atq > 0 and atq_lag1 > 0 ;
1057      size   = log(atq);
1058      size_l = log(atq_lag1);
1059      lvrg_l = bd/atq_lag1;
1060      lvrg   = dlttq/atq;
1061      if lvrg eq . then lvrg = 0 ;
1062  run;

WARNING: The variable niq_l in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      227702 at 1059:16   8651 at 1060:19     
NOTE: There were 1125340 observations read from the data set RAWDATA.COMP_FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.26 seconds
      

1063  proc sort data=fundq_clean nodupkey; by gvkey datadate; run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.26 seconds
      cpu time            0.39 seconds
      

1064  
1065  %let winsVars2 = saleq revq ;
1066  %winsor(dsetin=work.fundq_clean, dsetout=work.fundq_clean, byvar=fyearq, vars=&winsVars2,
1066! type=winsor, pctl=1 99);

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.XTEMP has 1012247 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.17 seconds
      cpu time            0.17 seconds
      


NOTE: There were 1012247 observations read from the data set WORK.XTEMP.
NOTE: The data set WORK.XTEMP has 1012247 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.29 seconds
      cpu time            0.48 seconds
      


NOTE: The data set WORK.XTEMP_PCTL has 30 observations and 5 variables.
NOTE: PROCEDURE UNIVARIATE used (Total process time):
      real time           0.72 seconds
      cpu time            0.71 seconds
      


WARNING: The variable xbyvar in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 1012247 observations read from the data set WORK.XTEMP.
NOTE: There were 30 observations read from the data set WORK.XTEMP_PCTL.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: DATA statement used (Total process time):
      real time           0.23 seconds
      cpu time            0.21 seconds
      

1067  
1068  *get more fundq vars;
1069  data fundq_add; set comp.fundq_1950_2021;
1070      keep gvkey datadate intanq;
1071      where datadate>'01JAN1990'd;
1072  run;

NOTE: There were 1441077 observations read from the data set COMP.FUNDQ_1950_2021.
      WHERE datadate>'01JAN1990'D;
NOTE: The data set WORK.FUNDQ_ADD has 1441077 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.28 seconds
      cpu time            0.28 seconds
      

1073  
1074  proc sort data=fundq_add nodupkey; by gvkey datadate; run;

NOTE: There were 1441077 observations read from the data set WORK.FUNDQ_ADD.
NOTE: 1238 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDQ_ADD has 1439839 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.07 seconds
      cpu time            0.18 seconds
      

1075  proc sort data=fundq_clean nodupkey; by gvkey datadate; run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 40 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.26 seconds
      cpu time            0.43 seconds
      

1076  data fundq_clean;
1077      merge fundq_clean(in=a) fundq_add (in=b);
1078      by gvkey datadate;
1079      if a;
1080  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: There were 1439839 observations read from the data set WORK.FUNDQ_ADD.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 41 variables.
NOTE: DATA statement used (Total process time):
      real time           0.28 seconds
      cpu time            0.28 seconds
      

1081  
1082  * Create calendar date of fiscal period end in Compustat extract;
1083  data fundq_clean; set fundq_clean;
1084     if (1<=fyr<=5) then date_fyend=intnx('month',mdy(fyr,1,fyearq+1),0,'end');
1085     else if (6<=fyr<=12) then date_fyend=intnx('month',mdy(fyr,1,fyearq),0,'end');
1086     fqenddt=intnx('month',date_fyend,-3*(4-fqtr),'end');
1087     format fqenddt date9.;
1088     drop date_fyend;
1089  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 42 variables.
NOTE: DATA statement used (Total process time):
      real time           0.45 seconds
      cpu time            0.45 seconds
      

1090  
1091  * calculate moving sum of quarterly loss;
1092  data fundq_clean; set fundq_clean;
1093      if niq <=0 then lossq = 1 ; else lossq = 0;
1094  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 43 variables.
NOTE: DATA statement used (Total process time):
      real time           0.21 seconds
      cpu time            0.20 seconds
      

1095  
1096  proc sort data=fundq_clean; by gvkey datadate; run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 43 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.27 seconds
      cpu time            0.40 seconds
      

1097  proc expand data=fundq_clean out=fundq_clean;
1098      by gvkey ;
1099      id datadate;
1100      convert lossq = sum_lossq12 / transformout=(movsum 16);
1101      convert niq = ma_niq12 / transformout=(movave 16);
1102      convert ibq = sd_niq12 / transformout=(movstd 16);
1103      convert roaq = sd_roaq12 / transformout=(movstd 16);
1104  run;

WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=009879
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=010673
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013260
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013530
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013938
WARNING: The variable niq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ibq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable roaq has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=060976
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 47 variables.
NOTE: PROCEDURE EXPAND used (Total process time):
      real time           1.44 seconds
      cpu time            1.45 seconds
      

1105  
1106  data fundq_clean; set fundq_clean;
1107      drop datadate;
1108  run;

NOTE: There were 1012247 observations read from the data set WORK.FUNDQ_CLEAN.
NOTE: The data set WORK.FUNDQ_CLEAN has 1012247 observations and 46 variables.
NOTE: DATA statement used (Total process time):
      real time           0.22 seconds
      cpu time            0.23 seconds
      

1109  
1110  * add funda vars ;
1111  data funda_clean;
1112      set rawdata.comp_funda_clean2020;
1113      if at>0 & at_l>0;
1114      asize   = log(at);
1115      asize_l = log(at_l);
1116      bm_ann = bm;
1117      roa2 = ib_l/at_l;
1118      if ni < 0 then loss_a = 1; else loss_a = 0;
1119      where datadate ne . and at>0;
1120      label asize = "Log(AT)"
1121      asize_l = "Log(AT_l)" ;
1122  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      272 at 1117:16   
NOTE: There were 182044 observations read from the data set RAWDATA.COMP_FUNDA_CLEAN2020.
      WHERE (datadate not = .) and (at>0);
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 118 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.09 seconds
      

1123  proc sort data=funda_clean nodupkey ; by gvkey fyear; run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 118 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.15 seconds
      cpu time            0.23 seconds
      

1124  
1125  proc expand data=funda_clean out=funda_clean;
1126      by gvkey;
1127      id fyear;
1128      convert loss_a = sum_loss_a5 / transformout=(movsum 10);
1129      convert roa2 = ma_roa5 / transformout=(movstd 10);
1130      convert ib = ma_ni5 / transformout=(movstd 10);
1131  run;

WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=009879
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=012161
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013260
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=013530
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=028379
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=030719
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=031810
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=065561
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=065844
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=066707
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=110320
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
WARNING: The variable ib has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=129631
WARNING: The variable roa2 has only 0 nonmissing observations, which is too few to apply the 
         conversion method. The result series is set to missing.
NOTE: The above message was for the following BY group:
      Global Company Key=144564
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 121 variables.
NOTE: PROCEDURE EXPAND used (Total process time):
      real time           0.56 seconds
      cpu time            0.54 seconds
      

1132  
1133  * add additional funda vars;
1134  data funda_add; set compa.funda_1950_2021;
1135      keep gvkey datadate intan ;
1136  run;

NOTE: There were 861623 observations read from the data set COMPA.FUNDA_1950_2021.
NOTE: The data set WORK.FUNDA_ADD has 861623 observations and 3 variables.
NOTE: DATA statement used (Total process time):
      real time           0.14 seconds
      cpu time            0.14 seconds
      

1137  proc sort data=funda_add nodupkey; by gvkey datadate; run;

NOTE: There were 861623 observations read from the data set WORK.FUNDA_ADD.
NOTE: 307572 observations with duplicate key values were deleted.
NOTE: The data set WORK.FUNDA_ADD has 554051 observations and 3 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.14 seconds
      

1138  
1139  data funda_clean;
1140      merge funda_clean(in=a) funda_add(in=b);
1141      by gvkey datadate;
1142      if a;
1143  run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: There were 554051 observations read from the data set WORK.FUNDA_ADD.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 122 variables.
NOTE: DATA statement used (Total process time):
      real time           0.14 seconds
      cpu time            0.14 seconds
      

1144  
1145  * Calculate firm age;
1146  data funda_clean ;
1147      set funda_clean;
1148      by gvkey;
1149      if first.gvkey then
1150          firm_age=0;
1151      firm_age + 1;
1152  run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 123 variables.
NOTE: DATA statement used (Total process time):
      real time           0.10 seconds
      cpu time            0.09 seconds
      

1153  proc sort data=funda_clean; by gvkey fyear;  run;

NOTE: There were 181286 observations read from the data set WORK.FUNDA_CLEAN.
NOTE: The data set WORK.FUNDA_CLEAN has 181286 observations and 123 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.15 seconds
      cpu time            0.18 seconds
      

1154  
1155  * Calculate the mean, median, and standard deviation by industry ;
1156  proc sql;
1157      create table funda_clean as
1158      select *,
1159          mean(firm_age) as ind_mean_firm_age label="Industry mean firm age",
1160          median(firm_age) as ind_med_firm_age label="Industry median firm age",
1161          std(firm_age) as ind_std_firm_age label="Industry Std firm age"
1162      from funda_clean
1163      group by sic2, fyear
1164      order by gvkey, fyear;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.FUNDA_CLEAN created, with 181286 rows and 126 columns.

1165  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.38 seconds
      cpu time            0.62 seconds
      

1166  
1167  * Merge stacked data and firm characteristics;
1168  data StateName;
1169      set rawdata.firmStateName;
1170  run;

NOTE: There were 41696 observations read from the data set RAWDATA.FIRMSTATENAME.
NOTE: The data set WORK.STATENAME has 41696 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1171  
1172  proc sql;
1173      create table Analysis as
1174      select  a.*,b.*,
1175              c.StateName label="Firm HQ State", c.ST label="State",
1176              d.at, d.at_l, d.sale, d.sale_l, d.ni, d.ib, d.ibc,
1177              d.firm_age, d.ind_mean_firm_age, d.ind_std_firm_age, d.ind_med_firm_age,
1178              d.revt, d.revt_l, d.ceq, d.datadate as datadate_ann, d.xrd, d.intan,
1179              d.ma_roa5, d.ma_ni5, d.sum_loss_a5
1180      from    Analysis as a
1181      left join fundq_clean as b
1182          on  a.gvkey=b.gvkey and a.rdq=b.rdq
1183      left join StateName as c
1184          on  a.gvkey=c.gvkey
1185      left join funda_clean as d
1186          on  a.gvkey=d.gvkey and a.fyearq=d.fyear ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable fyearq already exists on file WORK.ANALYSIS.
WARNING: Variable fqtr already exists on file WORK.ANALYSIS.
WARNING: Variable fyr already exists on file WORK.ANALYSIS.
WARNING: Variable rdq already exists on file WORK.ANALYSIS.
WARNING: Variable dlcq already exists on file WORK.ANALYSIS.
WARNING: Variable dlttq already exists on file WORK.ANALYSIS.
WARNING: Variable ibq already exists on file WORK.ANALYSIS.
WARNING: Variable ltq already exists on file WORK.ANALYSIS.
WARNING: Variable niq already exists on file WORK.ANALYSIS.
WARNING: Variable oiadpq already exists on file WORK.ANALYSIS.
WARNING: Variable oibdpq already exists on file WORK.ANALYSIS.
WARNING: Variable ppegtq already exists on file WORK.ANALYSIS.
WARNING: Variable saleq already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 50328 rows and 331 columns.

1187  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2.10 seconds
      cpu time            2.71 seconds
      

1188  
1189  proc sql;
1190      create table Analysis as
1191      select *,
1192          max(firm_age) as firm_age2
1193      from Analysis
1194      group by cid, gvkey, year(datadate)
1195      order by cid, pairid, gvkey, rdq;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 50328 rows and 332 columns.

1196  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.40 seconds
      cpu time            1.70 seconds
      

1197  
1198  proc sql;
1199      create table Analysis as
1200      select *,
1201          mean(firm_age) as ind_mean_firm_age2 label="Industry mean firm age",
1202          median(firm_age) as ind_med_firm_age2 label="Industry median firm age",
1203          std(firm_age) as ind_std_firm_age2 label="Industry Std firm age"
1204      from Analysis
1205      group by cid, sic2
1206      order by cid, pairid, gvkey, rdq;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 50328 rows and 335 columns.

1207  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.35 seconds
      cpu time            1.65 seconds
      

1208  
1209  data Analysis; set Analysis;
1210      calyear = year(datadate_ann);
1211      if calyear = . then calyear = year(fqenddt);
1212      calqtr = qtr(datadate);
1213  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      3559 at 1210:15   126 at 1211:35    
NOTE: There were 50328 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 50328 observations and 337 variables.
NOTE: DATA statement used (Total process time):
      real time           0.40 seconds
      cpu time            0.40 seconds
      

1214  
1215  * compute the average inst ownership over the fiscal year;
1216  proc sql;
1217      create table Analysis as
1218      select *, avg(ior) as avg_ior label="Average Qtr IOR" format comma8.4
1219      from Analysis
1220      group by gvkey, fyearq
1221      order by cid, gvkey, rdq;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 50328 rows and 338 columns.

1222  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.37 seconds
      cpu time            1.68 seconds
      

1223  data Analysis;
1224      retain gvkey fyearq fqtr rdq datadate ANNOUNCE_DATE treated post qd_rel cid pairid qd;
1225      set Analysis;
1226      if cmiss (of relstkpick1 ) eq 0;
1227  run;

NOTE: There were 50328 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33897 observations and 338 variables.
NOTE: DATA statement used (Total process time):
      real time           0.35 seconds
      cpu time            0.34 seconds
      

1228  
1229  
1230  /* ************************************************************************ */
1231  * make some vars to check the number of non-missing Relstkpick ;
1232  /* ************************************************************************ */
1233  * COUNTER is a cummulative number: 0,1,2,3,4,5 ;
1234  proc sort data=Analysis; by cid gvkey post; run;

NOTE: There were 33897 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33897 observations and 338 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.40 seconds
      cpu time            0.39 seconds
      

1235  data Analysis;
1236      set Analysis;
1237      by cID gvkey post;
1238      if first.post then COUNTER=0;
1239      COUNTER+(Relstkpick1 ne .);
1240  run;

NOTE: There were 33897 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33897 observations and 339 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.28 seconds
      

1241  
1242  proc sql;
1243      create table Analysis as
1244      select *,
1245          max(COUNTER) as COUNTER_BY_POST
1246      from Analysis
1247      group by cID, gvkey, post
1248      order by cid, gvkey, qd_rel ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33897 rows and 340 columns.

1249  
1250      create table Analysis as
1251      select *,
1252          min(post) as MIN_POST,
1253          max(post) as MAX_POST,
1254          min(COUNTER_BY_POST) as MIN_NOBS_PRE_POST
1255      from Analysis
1256      group by cID, gvkey
1257      order by cid, gvkey, qd_rel ;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33897 rows and 343 columns.

1258  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           1.54 seconds
      cpu time            1.92 seconds
      

1259  proc sort data=Analysis ; by cID PairID treated gvkey datadate; run;

NOTE: There were 33897 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33897 observations and 343 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.39 seconds
      cpu time            0.40 seconds
      

1260  proc sort data=Analysis nodupkey; by cID treated gvkey datadate; run;

NOTE: There were 33897 observations read from the data set WORK.ANALYSIS.
NOTE: 458 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 33439 observations and 343 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.39 seconds
      cpu time            0.39 seconds
      

1261  
1262  * destring SIC;
1263  data Analysis;  set Analysis;   sic_num = input(sic, 8.); label sic_num="Standard Industry
1263! Classification Code"; drop sic; run;

NOTE: There were 33439 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33439 observations and 342 variables.
NOTE: DATA statement used (Total process time):
      real time           0.27 seconds
      cpu time            0.28 seconds
      

1264  data Analysis;  set Analysis;   rename sic_num = sic; run;

NOTE: There were 33439 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33439 observations and 342 variables.
NOTE: DATA statement used (Total process time):
      real time           0.26 seconds
      cpu time            0.26 seconds
      

1265  proc sort data=Analysis nodupkey; by cid gvkey datadate; run;

NOTE: There were 33439 observations read from the data set WORK.ANALYSIS.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 33439 observations and 342 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.39 seconds
      cpu time            0.39 seconds
      

1266  
1267  
1268  /* ************************************************************************ */
1269  /* ***********************  PART 3: OTHER DATASET  ************************ */
1270  /* ************************************************************************ */
1271  * Analyst forecast and Analyst following;
1272  data afc; set rawdata.afc_fundq;
1273      keep gvkey fyearq datadate rdq numest lnanalys repdats ryear ;
1274      lnanalys = log(1+numest);
1275      if lnanalys ne . ;
1276      ryear = year(repdats);
1277  run;

NOTE: Missing values were generated as a result of performing an operation on missing values.
      Each place is given by: (Number of times) at (Line):(Column).
      480890 at 1274:16   480890 at 1274:21   
NOTE: There were 988699 observations read from the data set RAWDATA.AFC_FUNDQ.
NOTE: The data set WORK.AFC has 507809 observations and 8 variables.
NOTE: DATA statement used (Total process time):
      real time           0.11 seconds
      cpu time            0.12 seconds
      

1278  proc sort data=afc nodupkey ; by gvkey repdats; run;

NOTE: There were 507809 observations read from the data set WORK.AFC.
NOTE: 1183 observations with duplicate key values were deleted.
NOTE: The data set WORK.AFC has 506626 observations and 8 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.10 seconds
      

1279  
1280  proc sql;
1281      create table afc as
1282      select  distinct gvkey, ryear, datadate,
1283              max(numest) as numest_max label="Max #Analyst (year)",
1284              max(lnanalys) as lnanalys_max label="Max #LnAnalyst (year)"
1285      from    afc
1286      group by gvkey, ryear
1287      order by gvkey, datadate;
NOTE: The query requires remerging summary statistics back with the original data.
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.AFC created, with 506626 rows and 5 columns.

1288  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           0.17 seconds
      cpu time            0.28 seconds
      

1289  
1290  * Stock illiquidity (AIM);
1291  data aim; set rawdata.aim; run;

NOTE: There were 649518 observations read from the data set RAWDATA.AIM.
NOTE: The data set WORK.AIM has 649518 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.03 seconds
      

1292  proc sort data=aim nodupkey; by gvkey datadate; run;

NOTE: There were 649518 observations read from the data set WORK.AIM.
NOTE: 374 observations with duplicate key values were deleted.
NOTE: The data set WORK.AIM has 649144 observations and 9 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.07 seconds
      cpu time            0.10 seconds
      

1293  
1294  * Price synchronicity (Morck et al 2002);
1295  data psynch ; set rawdata.pinfo_qtr_retx6d; run;

NOTE: There were 515792 observations read from the data set RAWDATA.PINFO_QTR_RETX6D.
NOTE: The data set WORK.PSYNCH has 515792 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

1296  proc sort data=psynch; by gvkey fyear fqtr; run;

NOTE: There were 515792 observations read from the data set WORK.PSYNCH.
NOTE: The data set WORK.PSYNCH has 515792 observations and 9 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.09 seconds
      

1297  
1298  data psynch; set psynch;
1299      by gvkey fyear fqtr;
1300      if last.fqtr;
1301  run;

NOTE: There were 515792 observations read from the data set WORK.PSYNCH.
NOTE: The data set WORK.PSYNCH has 515774 observations and 9 variables.
NOTE: DATA statement used (Total process time):
      real time           0.04 seconds
      cpu time            0.04 seconds
      

1302  
1303  * read the Bushee's IICLASS data;
1304  data io_class;
1305      set rawdata.io_class2022qtr;
1306      rqtr = qtr(rdate);
1307      ryear = year(rdate);
1308  run;

NOTE: There were 737259 observations read from the data set RAWDATA.IO_CLASS2022QTR.
NOTE: The data set WORK.IO_CLASS has 737259 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.07 seconds
      cpu time            0.07 seconds
      

1309  
1310  * Financial constraints;
1311  data constraints; set rawdata.constraints; run;

NOTE: There were 162789 observations read from the data set RAWDATA.CONSTRAINTS.
NOTE: The data set WORK.CONSTRAINTS has 162789 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1312  
1313  * Opacity;
1314  data AFERR;
1315      set rawdata.AFERR;
1316      fpeyear = year(FPEDATS);
1317      drop fyear;
1318  run;

NOTE: There were 124683 observations read from the data set RAWDATA.AFERR.
NOTE: The data set WORK.AFERR has 124683 observations and 14 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1319  proc sort data=AFERR nodupkey; by gvkey fpeyear; run;

NOTE: There were 124683 observations read from the data set WORK.AFERR.
NOTE: 14 observations with duplicate key values were deleted.
NOTE: The data set WORK.AFERR has 124669 observations and 14 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1320  data AFERR; set AFERR; drop fpeyear; run;

NOTE: There were 124669 observations read from the data set WORK.AFERR.
NOTE: The data set WORK.AFERR has 124669 observations and 13 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds
      

1321  
1322  * Ivol quarterly;
1323  data retvol; set rawdata.retvolqtr_112824;run;

NOTE: There were 519328 observations read from the data set RAWDATA.RETVOLQTR_112824.
NOTE: The data set WORK.RETVOL has 519328 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.03 seconds
      

1324  proc sort data=retvol nodupkey; by gvkey enddt; run;

NOTE: There were 519328 observations read from the data set WORK.RETVOL.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.RETVOL has 519328 observations and 7 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.05 seconds
      cpu time            0.07 seconds
      

1325  
1326  * abnormal volume trading;
1327  data abvolume; set rawdata.abvolume; run;

NOTE: There were 747275 observations read from the data set RAWDATA.ABVOLUME.
NOTE: The data set WORK.ABVOLUME has 747275 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds
      

1328  proc sort data=abvolume nodupkey; by gvkey fyearq fqtr; run;

NOTE: There were 747275 observations read from the data set WORK.ABVOLUME.
NOTE: 29080 observations with duplicate key values were deleted.
NOTE: The data set WORK.ABVOLUME has 718195 observations and 6 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.06 seconds
      cpu time            0.15 seconds
      

1329  
1330  * CAR at meeting dates to activism data;
1331  data car_meetingdt1; set rawdata.car_meetingdt_capm_00;
1332      rename car = car_meeting00;
1333      label car = "AR[0] Meeting dt";
1334  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_00.
NOTE: The data set WORK.CAR_MEETINGDT1 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1335  proc sort data=car_meetingdt1 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT1.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT1 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1336  
1337  data car_meetingdt2; set rawdata.car_meetingdt_capm_01;
1338      rename car = car_meeting01;
1339      label car = "CAR[0+1] Meeting dt";
1340  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_01.
NOTE: The data set WORK.CAR_MEETINGDT2 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1341  proc sort data=car_meetingdt2 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT2.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT2 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1342  
1343  data car_meetingdt3; set rawdata.car_meetingdt_capm_11_round2;
1344      rename car = car_meeting11;
1345      label car = "CAR[-1+1] Meeting dt";
1346  run;

NOTE: There were 1846 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_11_ROUND2.
NOTE: The data set WORK.CAR_MEETINGDT3 has 1846 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1347  proc sort data=car_meetingdt3 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1846 observations read from the data set WORK.CAR_MEETINGDT3.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT3 has 1846 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1348  
1349  data car_meetingdt4; set rawdata.car_meetingdt_capm_17;
1350      rename car = car_meeting17;
1351      label car = "CAR[+1+7] Meeting dt";
1352  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_17.
NOTE: The data set WORK.CAR_MEETINGDT4 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1353  proc sort data=car_meetingdt4 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT4.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT4 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1354  
1355  data car_meetingdt5; set rawdata.car_meetingdt_capm_27_round2;
1356      rename car = car_meeting27;
1357      label car = "CAR[+2+7] Meeting dt";
1358  run;

NOTE: There were 1846 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_27_ROUND2.
NOTE: The data set WORK.CAR_MEETINGDT5 has 1846 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1359  proc sort data=car_meetingdt5 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1846 observations read from the data set WORK.CAR_MEETINGDT5.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT5 has 1846 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1360  
1361  data car_meetingdt6; set rawdata.car_meetingdt_capm_214;
1362      rename car = car_meeting214;
1363      label car = "CAR[+2+14] Meeting dt";
1364  run;

NOTE: There were 1826 observations read from the data set RAWDATA.CAR_MEETINGDT_CAPM_214.
NOTE: The data set WORK.CAR_MEETINGDT6 has 1826 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1365  proc sort data=car_meetingdt6 nodupkey; by pairid treated gvkey ANNOUNCE_DATE ; run;

NOTE: There were 1826 observations read from the data set WORK.CAR_MEETINGDT6.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.CAR_MEETINGDT6 has 1826 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1366  
1367  *compute the sum of Large and Small MFOR immediately before 13D;
1368  data mfor_13d; set rawdata.mfor_13d;run;

NOTE: There were 856 observations read from the data set RAWDATA.MFOR_13D.
NOTE: The data set WORK.MFOR_13D has 856 observations and 10 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds
      

1369  proc sort data=mfor_13d nodupkey; by gvkey CAMPAIGN_ID; run;

NOTE: There were 856 observations read from the data set WORK.MFOR_13D.
NOTE: 4 observations with duplicate key values were deleted.
NOTE: The data set WORK.MFOR_13D has 852 observations and 10 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1370  
1371  * Investor Relation (IR) data;
1372  data ir; set rawdata.ir2_111624; run;

NOTE: There were 133334 observations read from the data set RAWDATA.IR2_111624.
NOTE: The data set WORK.IR has 133334 observations and 42 variables.
NOTE: DATA statement used (Total process time):
      real time           0.02 seconds
      cpu time            0.01 seconds
      

1373  
1374  * experience level of proxy solicitors;
1375  data advisory; set rawdata.advisory; run;

NOTE: There were 9262 observations read from the data set RAWDATA.ADVISORY.
NOTE: The data set WORK.ADVISORY has 9262 observations and 12 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1376  proc sort data=advisory nodupkey; by CAMPAIGN_ID; run;

NOTE: There were 9262 observations read from the data set WORK.ADVISORY.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ADVISORY has 9262 observations and 12 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1377  
1378  * Insider Ownership;
1379  data insider; set rawdata.insider; run;

NOTE: There were 48632 observations read from the data set RAWDATA.INSIDER.
NOTE: The data set WORK.INSIDER has 48632 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds
      

1380  
1381  
1382  * -------------------------------------------;
1383  * Merge datasets;
1384  * -------------------------------------------;
1385  proc sql;
1386  create table Analysis as
1387  select  a.*, b.*
1388  from    Analysis as a left join afc as b
1389  on      a.gvkey=b.gvkey and a.datadate = b.datadate ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable ryear already exists on file WORK.ANALYSIS.
WARNING: Variable datadate already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 344 columns.

1390  
1391  create table Analysis as
1392  select  a.*, b.insider_own
1393  from    Analysis as a left join insider as b
1394  on      a.gvkey=b.gvkey and a.datadate = b.datadate ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 345 columns.

1395  
1396  create table Analysis as
1397  select  a.*, b.aim, b.ln_oneplusaim, b.ln_aim
1398  from    Analysis as a left join aim as b
1399  on      a.gvkey=b.gvkey and a.datadate = b.datadate;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 348 columns.

1400  
1401  create table Analysis as
1402  select  a.*, b.psynch1,b.psynch2,b.psynch3,b.pinfo1,b.pinfo2,b.pinfo3
1403  from    Analysis as a left join psynch as b
1404  on      a.gvkey=b.gvkey and a.fyearq = b.fyear and a.fqtr=b.fqtr ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 354 columns.

1405  
1406  create table Analysis as
1407  select  a.*, b.*
1408  from    Analysis as a left join io_class as b
1409  on      a.gvkey=b.gvkey and a.fyearq=b.ryear and a.fqtr=b.rqtr ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable permno already exists on file WORK.ANALYSIS.
WARNING: Variable rdate already exists on file WORK.ANALYSIS.
WARNING: Variable ryear already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 363 columns.

1410  
1411  create table Analysis as
1412  select  a.*, b.kzindex,b.saindex,b.wwindex
1413  from    Analysis as a left join constraints as b
1414  on      a.gvkey=b.gvkey and a.fyearq=b.fyear+1  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 366 columns.

1415  
1416  create table Analysis as
1417  select  a.*, b.abvolume, b.volumeturn
1418  from    Analysis as a left join abvolume as b
1419  on      a.gvkey=b.gvkey and a.fyearq=b.fyearq and a.fqtr=b.fqtr;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 368 columns.

1420  
1421  create table Analysis as
1422  select  a.*, b.*
1423  from    Analysis as a left join retvol as b
1424  on      a.gvkey=b.gvkey and a.rdq=b.enddt;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 374 columns.

1425  
1426  create table Analysis as
1427  select  a.*, b.car_meeting00
1428  from    Analysis as a left join car_meetingdt1 as b
1429  on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 375 columns.

1430  
1431  create table Analysis as
1432  select  a.*, b.car_meeting01
1433  from    Analysis as a left join car_meetingdt2 as b
1434  on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 376 columns.

1435  
1436  create table Analysis as
1437  select  a.*, b.car_meeting11
1438  from    Analysis as a left join car_meetingdt3 as b
1439  on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 377 columns.

1440  
1441  create table Analysis as
1442  select  a.*, b.car_meeting17
1443  from    Analysis as a left join car_meetingdt4 as b
1444  on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 378 columns.

1445  
1446  create table Analysis as
1447  select  a.*, b.car_meeting27
1448  from    Analysis as a left join car_meetingdt5 as b
1449  on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 379 columns.

1450  
1451  create table Analysis as
1452  select  a.*, b.car_meeting214
1453  from    Analysis as a left join car_meetingdt6 as b
1454  on      a.gvkey=b.gvkey and a.pairid=b.pairid  ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 380 columns.

1455  
1456  create table Analysis as
1457  select  a.*, b.*
1458  from    Analysis as a left join AFERR as b
1459  on      a.gvkey=b.gvkey and
1460          year(a.datadate)=year(b.FPEDATS) ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33439 rows and 392 columns.

1461  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           7.31 seconds
      cpu time            8.21 seconds
      

1462  proc sort data=Analysis nodupkey; by cid gvkey rdq; run;

NOTE: There were 33439 observations read from the data set WORK.ANALYSIS.
NOTE: 44 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 33395 observations and 392 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.44 seconds
      cpu time            0.43 seconds
      

1463  
1464  * other datasets;
1465  proc sql;
1466  create table Analysis as
1467  select  a.*, b.*
1468  from    Analysis as a left join mfor_13d as b
1469  on      a.gvkey=b.gvkey and a.CAMPAIGN_ID=b.CAMPAIGN_ID ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable gvkey already exists on file WORK.ANALYSIS.
WARNING: Variable campaign_id already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33395 rows and 400 columns.

1470  
1471  create table Analysis as
1472  select  a.*, b.*
1473  from    Analysis as a left join advisory as b
1474  on      a.CAMPAIGN_ID=b.CAMPAIGN_ID ;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable CAMPAIGN_ID already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33395 rows and 411 columns.

1475  
1476  create table Analysis as
1477  select  a.*,
1478          b.ir_freq, b.ir_dum, b.ir_freq_ann, b.ir_max,
1479          b.ir_sic2, b.ir_std_sic2, b.ir_sic2_ann,
1480          b.ir_avg, b.ir_std, b.ir_min, b.ir_max,
1481          b.ir_avg_last4, b.ir_std_last4,
1482          b.ir_avg_last8, b.ir_std_last8,
1483          b.ir_avg_last12, b.ir_std_last12,
1484          b.ir_avg_last16, b.ir_std_last16,
1485          b.ir_freq_movave4, b.ir_freq_movave8, b.ir_freq_movave12, b.ir_freq_movave16,
1486          b.ir_freq_movstd4, b.ir_freq_movstd8, b.ir_freq_movstd12, b.ir_freq_movstd16
1487  from    Analysis as a left join ir as b
1488  on      a.gvkey=b.gvkey and
1489          year(a.rdq)=b.year and qtr(a.rdq)=b.quarter;
WARNING: This CREATE TABLE statement recursively references the target table. A consequence of 
         this is a possible data integrity problem.
WARNING: Variable ir_max already exists on file WORK.ANALYSIS.
NOTE: Table WORK.ANALYSIS created, with 33395 rows and 437 columns.

1490  quit;
NOTE: PROCEDURE SQL used (Total process time):
      real time           2.25 seconds
      cpu time            2.70 seconds
      

1491  proc sort data=Analysis nodupkey; by cid gvkey rdq; run;

NOTE: There were 33395 observations read from the data set WORK.ANALYSIS.
NOTE: 0 observations with duplicate key values were deleted.
NOTE: The data set WORK.ANALYSIS has 33395 observations and 437 variables.
NOTE: PROCEDURE SORT used (Total process time):
      real time           0.42 seconds
      cpu time            0.42 seconds
      

1492  
1493  * drop unwanted vars;
1494  data Analysis ;
1495      set Analysis;
1496      drop outcome_desc company_fee_desc dissident_fee_desc dir_off_own_desc
1496! campaign_synopsis campaign_title iso_country
1497      target: actfinanc: actlegal: actpr: ;
1498  run;

NOTE: There were 33395 observations read from the data set WORK.ANALYSIS.
NOTE: The data set WORK.ANALYSIS has 33395 observations and 393 variables.
NOTE: DATA statement used (Total process time):
      real time           0.19 seconds
      cpu time            0.18 seconds
      

1499  
1500  * Export data to Stata file;
1501  %let FFP =
1501! "C:\Users\hpham13\Projects\mf_activism\empirical\1_code\final_package_acceptance\assembledd
1501! ata_topx.dta";
1502  proc export data = Analysis outfile = &FFP. replace;
1502!                                                      run;

NOTE: The export data set has 33395 observations and 393 variables.
NOTE: "C:\Users\hpham13\Projects\mf_activism\empirical\1_code\final_package_acceptance\assembledd
      ata_topx.dta" file was successfully created.
NOTE: PROCEDURE EXPORT used (Total process time):
      real time           0.13 seconds
      cpu time            0.14 seconds
      

1503  
1504  proc printto;
1505  run;

